package model;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import persistencia.AcessaBanco;

public class FichaAction extends Action{

	public ActionForward execute(ActionMapping map, ActionForm form, HttpServletRequest
			request, HttpServletResponse response) throws Exception {
		AcessaBanco acessa = new AcessaBanco();
		FichaForm contForm = (FichaForm)form;
		FichaDeInscricao contato = new FichaDeInscricao();//new Contato(request.getParameter("nome"),request.getParameter("email"),request.getParameter("telefone"),request.getParameter("endereco") );
		contato = contForm.getFicha();
		contato.setCre(contForm.getCre());
		contato.setMonitoria(contForm.getMonitoria());
		contato.setPet(contForm.isPet());
		contato.setCurso(contForm.getCurso());
		contato.setEspecializacao(contForm.isEspecializacao());
		contato.setInstituicao_de_origem(contForm.getInstituicao_de_origem());
		contato.setId(contForm.getId());
		contato.setPoscomp(contForm.getPoscomp());
		contato.setPublicacoes(contForm.getPublicacoes());
		contato.setTempo_integral(contForm.isTempo_integral());
		contato.setAno_conclusao(contForm.getAno_conclusao());
		
		acessa.salvaFicha(contato);
		ActionForward a = new ActionForward();
		a = map.findForward("ok");
	
		request.setAttribute("nomes", acessa.getNomes());
		return a;
	}
	
}
